<?php
header("content-type:text/html;charset=utf-8");

$tel=$_POST["telephone"];
$num=$_POST["num"];
$site=$_POST["site"];
$sign = "";
$num1=$_POST["num1"];
$authcode = $_POST["authcode"];
if(empty($tel)||empty($site))
{
echo '<script>alert("手机号和站点不能为空！");location.href="slctel.html";</script>';
}

if($num1==$authcode)
{
require("connu.inc.php");

$selecttel = "SELECT * FROM userinfo WHERE tel='$tel'";

$resulttel = mysql_query($selecttel);

while($row = mysql_fetch_array($resulttel))
{
	if($num != $row["winnum"])
	{
		echo '<script>alert("手机号码'.$tel.'期数不正确");location.href="slctel.html";</script>';
	}
	if($row["whether"]==1)
	{
		echo '<script>alert("手机号码'.$tel.'已兑奖");location.href="slctel.html";</script>';
	}
	if($row["whether"]==0 && $num == $row["winnum"])
	{
		header("location:selectinfo.php?id=".$tel."&id1=".$num.""); 
	}

}

echo '<script>alert("手机号码'.$tel.'不存在");location.href="slctel.html";</script>';

$update = "UPDATE userinfo SET site='$site' WHERE tel='$tel'";
$r = mysql_query($update);
if(!mysql_affected_rows())
{
	echo '<script>alert("站点插入失败");location.href="slctel.html"</script>';
}


mysql_free_result($resulttel);
mysql_close($link);
}
else
{
	echo '<script>alert("验证码错误！");location.href="slctel.html";</script>'; 
}
?>